export function timeFix() {
  const time = new Date();
  const hour = time.getHours();
  return hour < 9
    ? "早上好"
    : hour <= 11
    ? "上午好"
    : hour <= 13
    ? "中午好"
    : hour < 20
    ? "下午好"
    : "晚上好";
}

export function welcome() {
  const arr = [
    "休息一会儿吧",
    "准备吃什么呢?",
    "要不要打一把 DOTA",
    "我猜你可能累了"
  ];
  const index = Math.floor(Math.random() * arr.length);
  return arr[index];
}

export function mergeOptins(oldOptins, newOptions) {
  for (const key in oldOptins) {
    if (Object.prototype.hasOwnProperty.call(oldOptins, key)) {
      //新对象中不存在，直接将老对象值赋予
      if (!newOptions[key]) {
        newOptions[key] = oldOptins[key];
      }
      //新老对象都有值，判断值是否为对象
      if (newOptions[key] && oldOptins[key]) {
        if (
          typeof newOptions[key] === "object" &&
          !Array.isArray(newOptions[key])
        ) {
          mergeOptins(oldOptins[key], newOptions[key]);
        }
      }
    }
  }
  return newOptions
}
